import Axios from 'axios'

let fetch = Axios.create({
  baseURL: "http://192.168.31.66:9090", // 这里是本地express启动的服务地址
  timeout: 5000 // request timeout
})
fetch.interceptors.request.use(config => {
  return config
}, error => {
  Promise.reject(error)
})

fetch.interceptors.response.use(async data => {
  return  data
}, error => {
  if (error.response) {
    if (error.response.status === 500) {
      console.log('服务器错误，请联系管理员处理')
    }
    return Promise.reject(error.response.data)
  } else {
    return Promise.reject(error)
  }
})

export default fetch
